package com.jz.banner.screen.widget

import android.content.Context
import android.util.AttributeSet
import cn.jzvd.JzvdStd
import com.jz.banner.screen.R

class MyFullJZVideoPlayer : JzvdStd {
    constructor(context: Context?) : super(context) {}
    constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs) {}


    override fun onStateError() {
        super.onStateError()
        mMyJZVideoPlayerListener?.onStateError()
    }

    override fun onStateAutoComplete() {
        super.onStateAutoComplete()
        mMyJZVideoPlayerListener?.onPlayComplete()
    }

//    override fun onCompletion() {
//        super.onCompletion()
//        mMyJZVideoPlayerListener?.onPlayComplete()
//    }

    override fun onStatePlaying() {
        mMyJZVideoPlayerListener?.onStartPlay()
        super.onStatePlaying()
    }

    override fun changeUiToPauseShow() {
        mMyJZVideoPlayerListener?.onPausePlay()
        super.changeUiToPauseShow()
    }

   // override fun showWifiDialog() {}

    var mMyJZVideoPlayerListener: MyJZVideoPlayerListener? = null

    override fun showWifiDialog() {
        if (state == STATE_PAUSE) {
            startButton.performClick()
        } else {
            startVideo()
        }
    }

    override fun setScreenFullscreen() {
        super.setScreenFullscreen()
    }

    interface MyJZVideoPlayerListener {
        fun onStartPlay()
        fun onPausePlay()
        fun onPlayComplete()
        fun onStateError()
    }

    override fun getLayoutId(): Int {
        return R.layout.jz_layout_std_full
    }
}


